/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package ac.ui.controls;

import javax.swing.JFormattedTextField;
import javax.swing.JSpinner;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.text.DefaultFormatter;

/**
 *
 * @author empcl_000
 */
public class PCLMoney extends PCLSpinner {

    private double val;

    public PCLMoney() {

        SpinnerModel model = new SpinnerNumberModel(0, 0, 100000000, .25);
        setModel(model);
        NumberEditor editor = new NumberEditor(this, "#,##0.###");

        setEditor(editor);

        JFormattedTextField field = (JFormattedTextField) editor.getComponent(0);
        DefaultFormatter formatter = (DefaultFormatter) field.getFormatter();
        formatter.setCommitsOnValidEdit(true);

        addChangeListener(new javax.swing.event.ChangeListener() {
            @Override
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                //  jsp_BalanceLimitStateChanged(evt);
            }
        });

    }
    /*
     public void jsp_BalanceLimitStateChanged(javax.swing.event.ChangeEvent evt) {
     JSpinner j = (JSpinner) evt.getSource();
     if (j.getValue() != null) {
     val = (double) j.getValue();
     }

     }
     */

    public double getVal() {
        double d = (double) this.getValue();;
        return d;
    }

    public void setVal(double val) {
        this.setValue(val);
    }
}
